//
//  WCImageManager.h
//  WC
//
//  Created by 杨鑫 on 15/5/21.
//  Copyright (c) 2015年 智康. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
//
#import "AFNetworking.h"

typedef NS_ENUM(NSInteger, WCImageType) {
    WCImageTypeNurse,
    WCImageTypePatient,
    WCImageTypePrivateImage,
    WCImageTypeImage
};

typedef NS_ENUM(NSInteger, WCImageSize) {
    WCImageSizeSmall,
    WCImageSizeBig
};

@interface WCImageManager : NSObject

/**
 *  获取单例的方法
 *
 *  @return WCImageManager
 */
+ (instancetype)sharedMg;

/**
 *  删除本地图片
 *
 *  @param type WCImageType
 */
- (void)deleteImgs;
- (void)deletePrivateImgs;
- (void)deleteImgsByType:(WCImageType)type;
- (void)removeImgsCache;

/**
 *  图片上传成功之后删除
 *
 *  @param name
 */
- (void)deleteImageAfterUpload:(NSString *)name;

/**
 *  保存待上传的图片
 *
 *  @param image
 *  @param name
 */
- (void)saveImageWaitUpload:(UIImage *)image byName:(NSString *)name;

/**
 *  缓存的本地图片大小
 *
 *  @return float m
 */
- (void)imgsSize:(void(^)(float))success;

/**
 *  下载图片
 *
 *  @param id    图片ID
 *  @param type  WCImageType
 *  @param size  WCImageSize
 *  @param cache BOOL
 *
 *  @return AFHTTPRequestOperation
 */
- (NSURLSessionDataTask *)downloadImage:(NSString *)stringId
                                     type:(WCImageType)type
                                     size:(WCImageSize)size
                                    cache:(BOOL)cache
                                  success:(void (^)(UIImage *image, NSString *stringId))success
                                  failure:(void (^)(NSError *error))failure;

/**
 *  上传图片, UIImage Data
 *
 *  @param image UIImage
 *  @param type  WCImageType
 */
- (NSURLSessionDataTask *)uploadImage:(NSArray *)images
                                multi:(BOOL)multi
                             progress:(void(^)(NSProgress *progress))up_progerss
                              success:(void (^)(id responseObject))success
                              failure:(void (^)(NSString *msg))failure;

/**
 *  从缓存或者文件系统读取图片
 *
 *  @param id    用户ID或者文件名
 *  @param type  图片类型，护士、患者和其他
 *  @param size  缩放图，还是原图
 *  @param cache 是否需要缓存
 *
 *  @return image or nil
 */
- (UIImage *)image:(NSString *)stringId type:(WCImageType)type size:(WCImageSize)size cache:(BOOL)cache;
- (UIImage *)imageForUpload:(NSString *)name;

/**
 *  判断本地缓存是否有图片
 *
 *  @param stringId 用户ID或者文件名
 *  @param type     图片类型，护士、患者和其他
 *  @param size     缩放图，还是原图
 *
 *  @return BOOL
 */
- (BOOL)hasImage:(NSString *)stringId type:(WCImageType)type size:(WCImageSize)size;

- (NSURLSessionDataTask *)uploadMultiImage:(NSArray *)imageArray
                                     success:(void (^)(id responseObject))success
                                     failure:(void (^)(NSString *msg))failure
                                    always:(void (^)(void)) always;

+ (void)downLoadOriImage:(NSString *)url completed:(void(^)(UIImage *image))comleteBolck;

@end
